package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.WikiListData;
import com.thinkcube.edutainment.service.viewitem.WikiListItem;
import com.thinkcube.edutainment.service.viewitem.WikiListItem_;

@EBean
public class WikiListAdapter extends BaseAdapter {

	List<WikiListData> wikiListData;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		WikiListItem wikiListItem;
		if (convertView == null) {
			wikiListItem = WikiListItem_.build(context);
		} else {
			wikiListItem = (WikiListItem) convertView;
		}

		wikiListItem.bind(getItem(position));

		return wikiListItem;
	}

	public List<WikiListData> getWikiListData() {
		return wikiListData;
	}

	public void setWikiListData(List<WikiListData> wikiData) {
		this.wikiListData = wikiData;
	}

	@Override
	public int getCount() {
		return wikiListData.size();
	}

	@Override
	public WikiListData getItem(final int position) {
		return wikiListData.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
